package edu.fit5046.mymonashmate.activity;


import java.util.HashMap;
import java.util.Map;

import edu.fit5046.mymonashmate.R;
import edu.fit5046.mymonashmate.utils.DetailInfo;
import android.app.Activity;
import android.os.Bundle;
import android.widget.EditText;

public class InfoActivity extends Activity{
	
	public static final int INFO_END = DetailInfo.INFO_PREVIOUSJOB + 1;
	private EditText editTextRegInfo[];
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		setContentView(R.layout.layout_info);
		initWidget();
		
		//getValue from mapActivity
		Bundle bundle = this.getIntent().getExtras();
		int stuID = bundle.getInt("stuID");
		
		//get info form network
		Map<String,String> map = getInfoFromNetwork();
		DetailInfo info = DetailInfo.toDetailInfo(map);
		
		updateView(info);
		
		super.onCreate(savedInstanceState);
	}
	
	private void initWidget(){
		editTextRegInfo = new EditText[INFO_END];
		editTextRegInfo[DetailInfo.INFO_NAME] = (EditText) findViewById(R.id.text_Name);
		editTextRegInfo[DetailInfo.INFO_SURNAME] = (EditText) findViewById(R.id.text_SurName);
		editTextRegInfo[DetailInfo.INFO_NICKMAKE] = (EditText) findViewById(R.id.text_NickName);
		editTextRegInfo[DetailInfo.INFO_COURSE] = (EditText) findViewById(R.id.text_Course);
		editTextRegInfo[DetailInfo.INFO_UNIT] = (EditText) findViewById(R.id.text_Unit);
		editTextRegInfo[DetailInfo.INFO_NATIONNANITY] = (EditText) findViewById(R.id.text_NNanity);
		editTextRegInfo[DetailInfo.INFO_FIRSTLANGUAGE] = (EditText) findViewById(R.id.text_FLanguage);
		editTextRegInfo[DetailInfo.INFO_SECONDLANGUAGE] = (EditText) findViewById(R.id.text_SLanguage);
		editTextRegInfo[DetailInfo.INFO_ADDRESS] = (EditText) findViewById(R.id.text_address);
		editTextRegInfo[DetailInfo.INFO_FAVOURITEFOOD] = (EditText) findViewById(R.id.text_FFood);
		editTextRegInfo[DetailInfo.INFO_FAVOURITEMOIVE] = (EditText) findViewById(R.id.text_FMovie);
		editTextRegInfo[DetailInfo.INFO_FAVOURITEUNIT] = (EditText) findViewById(R.id.text_FUnit);
		editTextRegInfo[DetailInfo.INFO_FAVOURITEPROLAN] = (EditText) findViewById(R.id.text_FProLanguage);
		editTextRegInfo[DetailInfo.INFO_CURRENTJOB] = (EditText) findViewById(R.id.text_CJob);
		editTextRegInfo[DetailInfo.INFO_PREVIOUSJOB] = (EditText) findViewById(R.id.text_PJob);
		
		for (int i = 0; i < INFO_END; i++) {
			editTextRegInfo[i].setEnabled(false);
		}
	}
	
	private void updateView(DetailInfo info){
		for(int i = 0; i < INFO_END; i++){
			editTextRegInfo[i].setText(info.getValue(i));
		}
	}
	
	private Map<String,String> getInfoFromNetwork(){
		Map<String,String> map = new HashMap<>();
		return map;
	}

}
